﻿#region Imports
using System;
using System.Collections.ObjectModel;
using System.IO;
using System.Windows.Media;
using PlayRandom.ViewModels;
#endregion Imports

namespace PlayRandom.Models
{
    public class FileDetails : BaseModel
    {
        #region Properties
        public string FilePath { get; set; }

        private string _FileName;
        public string FileName
        {
            get { return _FileName; }
            set { _FileName = value; RaisePropertyChanged("FileName"); }
        }

        /// <summary>
        /// File size (in Bytes)
        /// </summary>
        public long FileSize { get; set; }

        private Brush _ForeColour;
        public Brush ForeColour
        {
            get { return _ForeColour; }
            set { _ForeColour = value; RaisePropertyChanged("ForeColour"); }
        }

        private ObservableCollection<string> _Timestamps = new ObservableCollection<string>();
        public ObservableCollection<string> Timestamps
        {
            get { return _Timestamps; }
            set { _Timestamps = value; RaisePropertyChanged("Timestamps"); }
        }

        public eFavouritesOption FavReference { get; set; }
        #endregion Properties

        #region Constructors
        public FileDetails(string filePath)
            : this(filePath, MainViewModel.FAV_COLOUR_DEFAULT)
        {
        }

        public FileDetails(string filePath, Brush foreColor)
            : this(filePath, Path.GetFileNameWithoutExtension(filePath), foreColor)
        {
        }

        public FileDetails(string filePath, string fileName, Brush foreColor)
        {
            this.FilePath = filePath;
            this.FileName = fileName;
            this.ForeColour = foreColor;

            try
            {
                this.FileSize = new FileInfo(filePath).Length;
            }
            catch (Exception)
            {
                this.FileSize = -1;
            }
        }
        #endregion Constructors

        #region Methods
        public override string ToString()
        {
            return this.FileName;
        }
        #endregion Methods
    }
}
